package com.lineage.server.command.executor;

import com.lineage.server.model.Instance.L1DollInstance;
import com.lineage.server.model.Instance.L1ItemInstance;
import com.lineage.server.model.Instance.L1MonsterInstance;
import com.lineage.server.model.Instance.L1NpcInstance;
import com.lineage.server.model.Instance.L1PcInstance;
import com.lineage.server.model.Instance.L1TrapInstance;
import com.lineage.server.model.L1Object;
import com.lineage.server.serverpackets.S_Chat;
import com.lineage.server.serverpackets.S_ServerMessage;
import com.lineage.server.serverpackets.ServerBasePacket;
import java.util.Iterator;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

public class L1ShowNpcid implements L1CommandExecutor {
  private static final Log _log = LogFactory.getLog(L1ShowNpcid.class);
  
  public static L1CommandExecutor getInstance() {
    return new L1ShowNpcid();
  }
  
  public void execute(L1PcInstance pc, String cmdName, String arg) {
    try {
      Iterator<L1Object> iterator = pc.getKnownObjects().iterator();
      while (iterator.hasNext()) {
        L1Object object = iterator.next();
        if (object instanceof L1ItemInstance) {
          L1ItemInstance tg = (L1ItemInstance)object;
          pc.sendPackets((ServerBasePacket)new S_Chat((L1Object)tg, "ItemId:" + tg.getItemId()));
          continue;
        } 
        if (object instanceof L1PcInstance) {
          L1PcInstance tg2 = (L1PcInstance)object;
          pc.sendPackets((ServerBasePacket)new S_Chat(tg2, "Objid:" + tg2.getId()));
          continue;
        } 
        if (object instanceof L1TrapInstance) {
          L1TrapInstance tg3 = (L1TrapInstance)object;
          pc.sendPackets((ServerBasePacket)new S_Chat(object, "XY:" + tg3.getX() + "/" + tg3.getY()));
          continue;
        } 
        if (object instanceof com.lineage.server.model.Instance.L1PetInstance) {
          pc.sendPackets((ServerBasePacket)new S_Chat(object, "tg: Pet"));
          continue;
        } 
        if (object instanceof com.lineage.server.model.Instance.L1SummonInstance) {
          pc.sendPackets((ServerBasePacket)new S_Chat(object, "tg: Summon"));
          continue;
        } 
        if (object instanceof L1DollInstance) {
          L1DollInstance tg4 = (L1DollInstance)object;
          pc.sendPackets((ServerBasePacket)new S_Chat(object, "Over Time:" + tg4.get_time()));
          continue;
        } 
        if (object instanceof com.lineage.server.model.Instance.L1EffectInstance) {
          pc.sendPackets((ServerBasePacket)new S_Chat(object, "tg: Effect"));
          continue;
        } 
        if (object instanceof L1MonsterInstance) {
          L1MonsterInstance tg5 = (L1MonsterInstance)object;
          pc.sendPackets((ServerBasePacket)new S_Chat(object, "NpcId:" + tg5.getNpcId()));
          continue;
        } 
        if (!(object instanceof L1NpcInstance))
          continue; 
        L1NpcInstance tg6 = (L1NpcInstance)object;
        pc.sendPackets((ServerBasePacket)new S_Chat(object, "NpcId:" + tg6.getNpcId()));
      } 
    } catch (Exception e) {
      _log.error("错误的GM指令格式: " + getClass().getSimpleName() + " 执行的GM:" + pc.getName());
      pc.sendPackets((ServerBasePacket)new S_ServerMessage(261));
    } 
  }
}
